<html>
<head>
    <title>戴森球计划量化工具</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
    <script src="https://cdn.bootcss.com/vue/2.5.16/vue.min.js"></script>
     


    <script type="text/javascript">


        //配方 ，如果数据改变时有可能需要重置配方
        var data = [
            {
                //s ： 产物(可能多产物)
                //q ： 需求
                //n ： 数量(如果不提供就是1)
                //m ： 生产设备
                //t ： 生产时间(秒)
                s: [{ name: "宇宙矩阵" }], q:
                    [
                        { name: "蓝矩阵", n: 1 },
                        { name: "红矩阵", n: 1 },
                        { name: "黄矩阵", n: 1 },
                        { name: "紫矩阵", n: 1 },
                        { name: "绿矩阵", n: 1 },
                        { name: "反物质", n: 1 }
                    ], t: 15, m: "研究站", group: "产品"
            },

            {
                s: [{ name: "铁矿" }], q: [], m: "采矿机", t: 1
            },
            {
                s: [{ name: "铜矿" }], q: [], m: "采矿机", t: 1
            },
            {
                s: [{ name: "煤矿" }], q: [], m: "采矿机", t: 1
            },
            {
                s: [{ name: "石矿" }], q: [], m: "采矿机", t: 1
            },
            {
                s: [{ name: "钛石" }], q: [], m: "采矿机", t: 1
            },
            {
                s: [{ name: "原油" }], q: [], m: "原油萃取站", t: 1
            },
            {
                s: [{ name: "水" }], q: [], m: "抽水机", t: 1
            },
            {
                s: [{ name: "硅石" }], q: [], m: "采矿机", t: 1
            },
            {
                s: [{ name: "蓄电池满" }], q: [{ name: "蓄电池" }], m: "能量枢纽", t: 1
            },

            
            {
                s: [{ name: "蓝矩阵" }], q: [{ name: "磁线圈", n: 1 }, { name: "电路板", n: 1 }], t: 3, m: "研究站", group: "产品"
            },
            {
                s: [{ name: "红矩阵" }], q: [
                    { name: "高级石墨", n: 2 },
                    { name: "氢", n: 2 }
                ], t: 6, m: "研究站", group: "产品"
            },
            {
                s: [{ name: "黄矩阵" }], q: [
                    { name: "金刚石", n: 1 },
                    { name: "钛晶石", n: 1 }
                ], t: 8, m: "研究站", group: "产品"
            },
            {
                s: [{ name: "紫矩阵" }], q: [
                    { name: "处理器", n: 2 },
                    { name: "粒子带宽", n: 1 }
                ], t: 10, m: "研究站", group: "产品"
            },
            {
                s: [{ name: "绿矩阵", n: 2 }], q: [
                    { name: "量子芯片", n: 1 },
                    { name: "引力透镜", n: 1 }
                ], t: 24, m: "研究站", group: "产品"
            },

            {
                s: [{ name: "空间翘曲器", n: 8 }], group: "消耗品", m: "制作台", q: [
                    { name: "绿矩阵", n: 1 }
                ], t: 10
            },
            {
                s: [{ name: "空间翘曲器", n: 1 }], group: "消耗品", m: "制作台", q: [
                    { name: "引力透镜", n: 1 }
                ], t: 10
            },
            {
                s: [{ name: "氘核燃料棒", n: 1 }], group: "消耗品", m: "制作台", q: [
                    { name: "钛合金", n: 1 },
                    { name: "重氢", n: 10 },
                    { name: "超级磁场环", n: 1 }
                ], t: 6
            },
            {
                s: [{ name: "引力透镜", n: 1 }], group: "消耗品", m: "制作台", q: [
                    { name: "金刚石", n: 4 },
                    { name: "奇异物质", n: 1 }
                ], t: 6
            },


          


            {
                s: [{ name: "硅石" }], q: [{ name: "石矿", n: 10 }], m: "制作台", t: 10
            },
            {
                s: [{ name: "铁块" }], group: "组件", m: "冶炼设备", q: [
                    { name: "铁矿", n: 1 }
                ], t: 1
            },
            {
                s: [{
                    name: "钢材"
                }
                ], group: "组件", m: "冶炼设备", q: [
                    { name: "铁块", n: 3 }
                ], t: 3
            },
            {
                s: [{ name: "钛块" }], group: "组件", m: "冶炼设备", q: [{ name: "钛石", n: 2 }], t: 2
            },
            {
                s: [{
                    name: "铜块"
                }], group: "组件", m: "冶炼设备", q: [
                    { name: "铜矿", n: 1 }
                ], t: 1
            },

            {
                s: [{ name: "磁铁" }], group: "组件", m: "冶炼设备", q: [
                    { name: "铁矿", n: 1 }
                ], t: 1.5
            },

            {
                s: [{ name: "磁线圈", n: 2 }], group: "组件", m: "制作台", q: [
                    { name: "磁铁", n: 2 },
                    { name: "铜块", n: 1 }
                ], t: 1
            },

            {
                s: [{ name: "电路板", n: 2 }], group: "组件", m: "制作台", q: [
                    { name: "铁块", n: 2 },
                    { name: "铜块", n: 1 }
                ], t: 1
            },

            {
                s: [{ name: "齿轮" }], group: "组件", m: "制作台", q: [
                    { name: "铁块", n: 1 }
                ], t: 1
            }, 
          
            {
                s: [{ name: "高级石墨" }], group: "组件", m: "冶炼设备", q: [
                    { name: "煤矿", n: 2 }
                ], t: 2
            },



            {
                s: [{ name: "重氢" }], group: "组件", m: "轨道采集器", q: [

                ], t: 1 / 0.02
            },
            {
                s: [{ name: "氢" }], group: "组件", m: "轨道采集器", q: [

                ], t: 1
            },
            {
                s: [{ name: "氢" }, { name: "精炼油", n: 2 }], group: "组件", m: "原油精炼机", q: [
                    { name: "原油", n: 2 }
                ], t: 4
            },

            //此配方不兼容程序
            //{
            //    s: [{ name: "氢", n: 3 }, { name: "高级石墨", n: 1 }], group: "组件", m: "原油精炼机", q: [
            //        { name: "氢", n: 2 },
            //        { name: "精炼油", n: 1 } 
            //    ], t: 4
            //},
            {
                s: [{ name: "氢", n: 1 }, { name: "石墨烯", n: 2 }], group: "组件", m: "化工设备", q: [
                    { name: "可燃冰", n: 2 }


                ], t: 2
            },
            {
                s: [{ name: "可燃冰" }], group: "组件", m: "轨道采集器", q: [

                ], t: 1
            },
            {
                s: [{ name: "可燃冰" }], group: "组件", m: "采矿机", q: [

                ], t: 1
            },
            {
                s: [{ name: "刺笋结晶" }], group: "组件", m: "采矿机", q: [

                ], t: 1
            },
            {
                s: [{ name: "玻璃", n: 1 }], group: "组件", m: "冶炼设备", q: [
                    { name: "石矿", n: 2 }
                ], t: 2
            },

            {
                s: [{ name: "棱镜", n: 2 }], group: "组件", m: "制作台", q: [
                    { name: "玻璃", n: 3 }
                ], t: 2
            },

            {
                s: [{ name: "高纯硅块", n: 1 }], group: "组件", m: "冶炼设备", q: [
                    { name: "硅石", n: 2 }
                ], t: 2
            },

            {
                s: [{ name: "微晶元件", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "高纯硅块", n: 2 },
                    { name: "铜块", n: 1 }
                ], t: 2
            },

            {
                s: [{ name: "处理器", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "电路板", n: 2 },
                    { name: "微晶元件", n: 2 }
                ], t: 3
            },

            {
                s: [{ name: "金刚石", n: 1 }], group: "组件", m: "冶炼设备", q: [
                    { name: "高级石墨", n: 1 }
                ], t: 2
            },

            {
                s: [{ name: "塑料", n: 1 }], group: "组件", m: "化工设备", q: [
                    { name: "精炼油", n: 2 },
                    { name: "高级石墨", n: 1 }
                ], t: 3
            },

            {
                s: [{ name: "有机晶体", n: 1 }], group: "组件", m: "化工设备", q: [
                    { name: "塑料", n: 2 },
                    { name: "精炼油", n: 1 },
                    { name: "水", n: 1 }
                ], t: 6
            },
            {
                s: [{ name: "有机晶体" }], group: "组件", m: "采矿机", q: [

                ], t: 1
            },
            {
                s: [{ name: "钛晶石", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "有机晶体", n: 1 },
                    { name: "钛块", n: 3 }
                ], t: 4
            },
            {
                s: [{ name: "晶格硅", n: 1 }], group: "组件", m: "冶炼设备", q: [
                    { name: "高纯硅块", n: 1 }
                ], t: 2
            },

            {
                s: [{ name: "石材", n: 1 }], group: "组件", m: "冶炼设备", q: [
                    { name: "石矿", n: 1 }
                ], t: 1
            },

            {
                s: [{ name: "电动机", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "铁块", n: 2 },
                    { name: "齿轮", n: 1 },
                    { name: "磁线圈", n: 1 }
                ], t: 2
            },
            {
                s: [{ name: "电磁涡轮", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "电动机", n: 2 },
                    { name: "磁线圈", n: 2 }
                ], t: 2
            },
            {
                s: [{ name: "硫酸", n: 4 }], group: "组件", m: "化工设备", q: [
                    { name: "精炼油", n: 6 },
                    { name: "石矿", n: 8 },
                    { name: "水", n: 4 }
                ], t: 6
            },
            {
                s: [{ name: "石墨烯", n: 2 }], group: "组件", m: "化工设备", q: [
                    { name: "硫酸", n: 1 },
                    { name: "高级石墨", n: 3 }
                ], t: 3
            },
            {
                s: [{ name: "碳纳米管", n: 2 }], group: "组件", m: "化工设备", q: [
                    { name: "石墨烯", n: 3 },
                    { name: "钛块", n: 1 }
                ], t: 4
            },

            {
                s: [{ name: "碳纳米管", n: 2 }], group: "组件", m: "化工设备", q: [
                    { name: "刺笋结晶", n: 2 }
                ], t: 4
            },

            {
                s: [{ name: "粒子带宽", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "碳纳米管", n: 2 },
                    { name: "晶格硅", n: 2 },
                    { name: "塑料", n: 1 }
                ], t: 8
            },
            {
                s: [{ name: "钛化玻璃", n: 2 }], group: "组件", m: "制作台", q: [
                    { name: "玻璃", n: 2 },
                    { name: "钛块", n: 2 },
                    { name: "水", n: 2 }
                ], t: 5
            }, {
                s: [{ name: "卡西米尔晶片", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "钛晶石", n: 1 },
                    { name: "石墨烯", n: 2 },
                    { name: "氢", n: 12 }
                ], t: 4
            }, {
                s: [{ name: "位面过滤器", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "卡西米尔晶片", n: 1 },
                    { name: "钛化玻璃", n: 2 }
                ], t: 12
            }
            , {
                s: [{ name: "量子芯片", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "处理器", n: 2 },
                    { name: "位面过滤器", n: 2 }
                ], t: 6
            }
            ,
            {
                s: [{ name: "粒子容器", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "电磁涡轮", n: 2 },
                    { name: "铜块", n: 2 },
                    { name: "石墨烯", n: 2 }
                ], t: 4
            },
            {
                s: [{ name: "重氢", n: 5 }], group: "组件", m: "粒子对撞机", q: [
                    { name: "氢", n: 10 }
                ], t: 5
            },
            {
                s: [{ name: "奇异物质", n: 1 }], group: "组件", m: "粒子对撞机", q: [
                    { name: "粒子容器", n: 2 },
                    { name: "铁块", n: 2 },
                    { name: "重氢", n: 10 }
                ], t: 8
            },
            {
                s: [{ name: "临界光子", n: 1 }], group: "组件", m: "射线接收塔", q: [
                ], t: 6
            },



            {
                s: [{ name: "反物质", n: 2 }, { name: "氢", n: 2 }], group: "组件", m: "粒子对撞机", q: [
                    { name: "临界光子", n: 2 }
                ], t: 2
            },

            {
                s: [{ name: "超级磁场环", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "电磁涡轮", n: 2 },
                    { name: "磁铁", n: 3 },
                    { name: "高级石墨", n: 1 }
                ], t: 3
            },
            {
                s: [{ name: "钛合金", n: 4 }], group: "组件", m: "冶炼设备", q: [
                    { name: "钛块", n: 4 },
                    { name: "钢材", n: 4 },
                    { name: "硫酸", n: 8 }
                ], t: 12
            },
            {
                s: [{ name: "电浆激发器", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "磁线圈", n: 4 },
                    { name: "棱镜", n: 2 }
                ], t: 2
            },
            {
                s: [{ name: "框架材料", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "碳纳米管", n: 4 },
                    { name: "钛合金", n: 1 },
                    { name: "高纯硅块", n: 1 }
                ], t: 6
            },
           
            {
                s: [{ name: "光子合并器", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "棱镜", n: 2 },
                    { name: "电路板", n: 1 }
                ], t: 3
            },
            {
                s: [{ name: "太阳帆", n: 2 }], group: "消耗品", m: "制作台", q: [
                    { name: "石墨烯", n: 1 },
                    { name: "光子合并器", n: 1 }
                ], t: 4
            },
            {
                s: [{ name: "戴森球组件", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "框架材料", n: 3 },
                    { name: "太阳帆", n: 3 },
                    { name: "处理器", n: 3 }
                ], t: 8
            },
            {
                s: [{ name: "小型运载火箭", n: 1 }], group: "消耗品", m: "制作台", q: [
                    { name: "戴森球组件", n: 2 },
                    { name: "氘核燃料棒", n: 2 },
                    { name: "量子芯片", n: 2 }
                ], t: 6
            },
           

            {
                s: [{ name: "硫酸", n: 1 }], group: "组件", m: "抽水机", q: [ 
                ], t: 1
            },
            {
                s: [{ name: "光栅石" }], q: [], m: "采矿机", t: 1
            }, {
                s: [{ name: "卡西米尔晶片", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "光栅石", n:6},
                    { name: "石墨烯", n: 2 },
                    { name: "氢", n: 12 }
                ], t: 4
            },
            {
                s: [{ name: "单极磁石" }], q: [], m: "采矿机", t: 1
            },
            {
                s: [{ name: "粒子容器", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "单极磁石", n: 10 },
                    { name: "铜块", n: 2 } 
                ], t: 4
            },

            {
                s: [{ name: "金伯利矿石" }], q: [], m: "采矿机", t: 1
            },
            {
                s: [{ name: "金刚石", n: 1 }], group: "组件", m: "冶炼设备", q: [
                    { name: "金伯利矿石", n: 1 }
                ], t: 2
            },
            {
                s: [{ name: "分形硅石" }], q: [], m: "采矿机", t: 1
            },
            {
                s: [{ name: "晶格硅", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "分形硅石", n: 1 }
                ], t:4
            },
            {
                s: [{ name: "地基", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "石材", n: 3 },
                    { name: "钢材", n: 1 }
                ], t: 1
            },
            {
                s: [{ name: "液氢燃料棒", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "钛块", n: 1 },
                    { name: "氢", n: 5 }
                ], t: 3
            },

            
            {
                s: [{ name: "电力感应塔", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "铁块", n: 2 },
                    { name: "磁线圈", n: 1 }
                ], t: 1
            },

            {
                s: [{ name: "无线输电塔", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "电力感应塔", n: 1 },
                    { name: "电浆激发器", n: 1 }
                ], t: 3
            },

            {
                s: [{ name: "卫星配电站", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "无线输电塔", n: 1 },
                    { name: "超级磁场环", n: 10 },
                    { name: "框架材料", n: 2 }
                ], t: 5
            },
            {
                s: [{ name: "风力涡轮机", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "铁块", n: 6 },
                    { name: "齿轮", n: 1 },
                    { name: "磁线圈", n: 3 }
                ], t: 4
            },
            {
                s: [{ name: "火力发电机", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "铁块", n: 10 },
                    { name: "石材", n: 4 },
                    { name: "齿轮", n: 4 },
                    { name: "磁线圈", n: 4 }
                ], t: 5
            },
            {
                s: [{ name: "传送带", n: 3 }], group: "建筑", m: "制作台", q: [
                    { name: "铁块", n: 2 },
                    { name: "齿轮", n: 1 }
                ], t: 1
            },
            {
                s: [{ name: "高速传送带", n: 3 }], group: "建筑", m: "制作台", q: [
                    { name: "传送带", n: 3 },
                    { name: "电磁涡轮", n: 1 }
                ], t: 1
            },
            {
                s: [{ name: "极速传送带", n: 3 }], group: "建筑", m: "制作台", q: [
                    { name: "高速传送带", n: 3 },
                    { name: "超级磁场环", n: 1 },
                    { name: "石墨烯", n: 1 }
                ], t: 1
            },
            {
                s: [{ name: "小型储物仓", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "铁块", n: 4 },
                    { name: "石材", n: 4 }
                ], t: 2
            },
            {
                s: [{ name: "大型储物仓", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "钢材", n: 8 },
                    { name: "石材", n: 8 }
                ], t: 4
            },
            {
                s: [{ name: "太阳能板", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "高纯硅块", n: 6 },
                    { name: "铜块", n: 6 },
                    { name: "电路板", n: 4 }
                ], t: 5
            },

            {
                s: [{ name: "蓄电池", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "铁块", n: 6 },
                    { name: "超级磁场环", n: 6 },
                    { name: "晶格硅", n: 4 }
                ], t: 5
            },

            {
                s: [{ name: "射线接收站", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "钢材", n: 20 },
                    { name: "高纯硅块", n: 20 },
                    { name: "光子合并器", n: 10 },
                    { name: "处理器", n: 5 },
                    { name: "超级磁场环", n: 20 }
                ], t: 8
            },

            {
                s: [{ name: "微型聚变发电站", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "钢材", n: 12 },
                    { name: "超级磁场环", n: 10 },
                    { name: "碳纳米管", n: 8 }, 
                    { name: "处理器", n: 4 }
                ], t: 10
            },
            {
                s: [{ name: "能量枢纽", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "钢材", n: 40 },
                    { name: "钛合金", n: 40 },
                    { name: "处理器", n: 40 },
                    { name: "粒子容器", n: 8 }
                ], t: 15
            },
            {
                s: [{ name: "储液灌", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "铁块", n: 8 },
                    { name: "石材", n: 4 },
                    { name: "玻璃", n: 4 }
                ], t: 2
            },

            
            {
                s: [{ name: "分拣器" }], group: "组件", m: "制作台", q: [
                    { name: "铁块", n: 1 },
                    { name: "电路板", n: 1 }
                ], t: 1
            },
            {
                s: [{ name: "高速分拣器", n: 2 }], group: "组件", m: "制作台", q: [
                    { name: "分拣器", n: 2 },
                    { name: "电动机", n: 1 }
                ], t: 1
            },

            {
                s: [{ name: "极速分拣器", n: 2 }], group: "组件", m: "制作台", q: [
                    { name: "高速分拣器", n: 2 },
                    { name: "电磁涡轮", n: 1 }
                ], t: 1
            },
            {
                s: [{ name: "采矿机", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "铁块", n: 4 },
                    { name: "电路板", n: 2 },
                    { name: "磁线圈", n: 2 },
                    { name: "齿轮", n: 2 }
                ], t: 3
            },
            {
                s: [{ name: "抽水机", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "铁块", n: 8 },
                    { name: "石材", n: 4 },
                    { name: "电动机", n: 4 },
                    { name: "电路板", n: 2 }
                ], t: 4
            },
            {
                s: [{ name: "原油萃取站", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "钢材", n: 12 },
                    { name: "石材", n: 12 },
                    { name: "电路板", n: 6 },
                    { name: "电浆激发器", n: 4 }
                ], t: 8
            },
            {
                s: [{ name: "原油精炼厂", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "钢材", n: 10 },
                    { name: "石材", n: 10 },
                    { name: "电路板", n: 6 },
                    { name: "电浆激发器", n: 6 }
                ], t: 6
            },
            {
                s: [{ name: "垂直发射井", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "钛合金", n: 80 },
                    { name: "框架材料", n: 30 },
                    { name: "引力透镜", n: 20 },
                    { name: "量子芯片", n: 10 }
                ], t: 30
            },
         
            
            {
                s: [{ name: "四向分流器", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "铁块", n: 3 },
                    { name: "齿轮", n: 2 },
                    { name: "电路板", n: 1 }
                ], t: 2
            },

            
            {
                s: [{ name: "制作台Mk.Ⅰ", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "铁块", n: 4 },
                    { name: "齿轮", n: 8 },
                    { name: "电路板", n: 4 }
                ], t: 2
            },
            {
                s: [{ name: "制作台Mk.Ⅱ", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "制作台Mk.Ⅰ", n: 1 },
                    { name: "石墨烯", n: 8 },
                    { name: "处理器", n: 4 }
                ], t: 3
            },
            {
                s: [{ name: "制作台Mk.Ⅲ", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "制作台Mk.Ⅱ", n: 1 },
                    { name: "粒子带宽", n: 8 },
                    { name: "量子芯片", n: 2 }
                ], t: 4
            },
            {
                s: [{ name: "制作台Mk.Ⅲ", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "制作台Mk.Ⅱ", n: 1 },
                    { name: "粒子带宽", n: 8 },
                    { name: "量子芯片", n: 2 }
                ], t: 4
            },
            {
                s: [{ name: "电弧熔炉", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "铁块", n: 4 },
                    { name: "石材", n: 2 },
                    { name: "电路板", n: 4 },
                    { name: "磁线圈", n: 2 }
                ], t: 3
            },
            {
                s: [{ name: "分馏塔", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "钢材", n: 8 },
                    { name: "石材", n: 4 },
                    { name: "玻璃", n: 4 },
                    { name: "处理器", n: 1 }
                ], t: 3
            },
            {
                s: [{ name: "化工厂", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "钢材", n: 8 },
                    { name: "石材", n: 8 },
                    { name: "玻璃", n: 8 },
                    { name: "电路板", n: 2 }
                ], t: 5
            },
            {
                s: [{ name: "矩阵研究站", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "铁块", n: 8 },
                    { name: "玻璃", n: 4 },
                    { name: "电路板", n: 4 },
                    { name: "磁线圈", n: 4 }
                ], t: 3
            },
            {
                s: [{ name: "电磁轨道弹射器", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "钢材", n: 20 },
                    { name: "齿轮", n: 20 },
                    { name: "处理器", n: 5 },
                    { name: "超级磁场环", n: 10 }
                ], t: 6
            },
            {
                s: [{ name: "行星内物流运输站", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "钢材", n: 40 },
                    { name: "钛块", n: 40 },
                    { name: "处理器", n: 40 },
                    { name: "粒子容器", n: 20 }
                ], t: 20
            },
            {
                s: [{ name: "微型粒子对撞机", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "钛合金", n: 20 },
                    { name: "框架材料", n: 20 },
                    { name: "超级磁场环", n: 50 },
                    { name: "石墨烯", n: 10 },
                    { name: "处理器", n: 8 }
                ], t: 15
            },
            {
                s: [{ name: "星际物流运输站", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "行星内物流运输站", n: 1 },
                    { name: "钛合金", n: 40 },
                    { name: "粒子容器", n: 20 }
                ], t: 30
            },
            {
                s: [{ name: "加力推进器", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "钛合金", n: 5},
                    { name: "电磁涡轮", n: 5 }
                ], t: 6
            },
            {
                s: [{ name: "轨道采集器", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "星际物流运输站", n: 1 },
                    { name: "超级磁场环", n: 50 },
                    { name: "加力推进器", n: 20 },
                    { name: "蓄电池满", n: 20 }
                ], t: 30
            },
            {
                s: [{ name: "推进器", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "钢材", n: 2 },
                    { name: "铜块", n: 3 }
                ], t: 4
            },
            {
                s: [{ name: "物流运输机", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "铁块", n: 5 },
                    { name: "处理器", n: 2 },
                    { name: "推进器", n: 2 }
                ], t: 4
            },
            {
                s: [{ name: "星际物流运输机", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "钛合金", n: 10 },
                    { name: "处理器", n: 10 },
                    { name: "加力推进器", n: 2 }
                ], t: 6
            },
            
           
            {
                s: [{ name: "光子合并器", n: 1 }], group: "组件", m: "射线接收塔", q: [
                    { name: "光栅石", n: 1 },
                    { name: "电路板", n: 1 }
                ], t: 3
            },


            {
                s: [{ name: "湮灭约束球", n: 1 }], group: "组件", m: "制作台", q: [
                    { name: "粒子容器", n: 1 },
                    { name: "处理器", n: 1 }
                ], t: 20
            },


            {
                s: [{ name: "反物质燃烧棒", n: 1 }], group: "消耗品", m: "制作台", q: [
                    { name: "反物质", n: 10 },
                    { name: "氢", n: 10 },
                    { name: "湮灭约束球", n: 1 },
                    { name: "钛合金", n: 1 }
                ], t: 12
            },


            {
                s: [{ name: "人造恒星", n: 1 }], group: "建筑", m: "制作台", q: [
                    { name: "钛合金", n: 20 },
                    { name: "框架材料", n: 10 },
                    { name: "湮灭约束球", n: 10 },
                    { name: "量子芯片", n: 10}
                ], t: 30
            }
            

            
            
        ]; 

        var energyData = {};
        energyData["研究站"] = 0.48;
        energyData["制作台Mk.Ⅰ"] = 0.27;
        energyData["制作台Mk.Ⅱ"] = 0.48;
        energyData["制作台Mk.Ⅲ"] = 0.78;
        energyData["电弧熔炉"] = 0.36;
        energyData["矿脉"] = 0.1;
        energyData["采矿机"] = 0.42; 
        energyData["原油萃取站"] = 0.84;
        energyData["抽水机"] = 0.3;
        energyData["原油精炼机"] = 0.96;
        energyData["化工厂"] = 0.72;
        energyData["粒子对撞机"] = 12;
        energyData["轨道采集器"] = 0;
        energyData["射线接收塔"] = 5;
        energyData["能量枢纽"] = 0;

        
        var version = "06";

        function f_initData() {


            $(data).each(function (i, item) {
                item.id = i;//配方的id，用index设置，data改变时应该重置配方

                var ms = [];
                if (item.m == "研究站") {
                    ms = [
                        { name: "研究站", speed: 1 }
                    ];
                }
                if (item.m == "制作台") {
                    ms = [
                        { name: "制作台Mk.Ⅰ", speed: 0.75 },
                        { name: "制作台Mk.Ⅱ", speed: 1 },
                        { name: "制作台Mk.Ⅲ", speed: 1.5 }
                    ];
                }

                if (item.m == "冶炼设备") {
                    ms = [
                        { name: "电弧熔炉", speed: 1 }
                    ];
                }
                if (item.m == "采矿机") {
                    ms = [
                        { name: "矿脉", speed: 0.5 * 1 },
                        { name: "采矿机", speed: 0.5 * 6 }  
                    ];
                }
                if (item.m == "能量枢纽") {
                    ms = [
                        { name: "能量枢纽", speed:  1 } 
                    ];
                }

                


                if (item.m == "原油萃取站") {
                    ms = [
                        { name: "原油萃取站", speed: 4 }
                    ];
                }
                if (item.m == "抽水机") {
                    ms = [
                        { name: "抽水机", speed: 70 / 60 }
                    ];
                }


                if (item.m == "原油精炼机") {
                    ms = [
                        { name: "原油精炼机", speed: 1 }
                    ];
                }
                if (item.m == "化工设备") {
                    ms = [
                        { name: "化工厂", speed: 1 }
                    ];
                }
                if (item.m == "粒子对撞机") {
                    ms = [
                        { name: "粒子对撞机", speed: 1 }
                    ];
                }
                if (item.m == "轨道采集器") {
                    ms = [
                        { name: "轨道采集器", speed: 9.6 }
                    ];
                }

                if (item.m == "射线接收塔") {
                    ms = [
                        { name: "射线接收塔", speed: 1 }
                    ];
                }


                item.m = ms;

            });
            console.log(data);
        }

        var settings = {};
        function saveSetting() {
            $.cookie('machine_settings' + version, JSON.stringify(settings));
        }
        function loadSetting() {
            var json = $.cookie('machine_settings' + version);
            if (json) {
                eval("settings = " + json);
            }
        }
        var settings_time = {};
        function saveSettingTime() {
            $.cookie('machine_settings_time' + version, JSON.stringify(settings_time));
        }
        function loadSettingTime() {
            var json = $.cookie('machine_settings_time' + version);
            if (json) {
                eval("settings_time = " + json);
            }
        }
        var settings_pf = {};
        function saveSettingPf() {
            $.cookie('machine_settings_pf' + version, JSON.stringify(settings_pf));
        }
        function loadSettingPf() {
            var json = $.cookie('machine_settings_pf' + version);
            if (json) {
                eval("settings_pf = " + json);
            }
        }
        var projects = [];
        function saveSettingProjects() {
            $.cookie('settings_projects' + version, JSON.stringify(projects));
        }
        function loadSettingProjects() {
            var json = $.cookie('settings_projects' + version);
            if (json) {
                eval("projects = " + json);
            }
        }
        //获取配方默认的机器
        function getMachine(name) {
            var item = find(name);
            if (!item) return null;
            var machine = settings[name] || null;
            if (machine != null) return machine;
            return item.m[0].name;
        }
        //获取时间  参数
        function getValue(name) {
            var item = find(name);
            if (!item) return null;
            var machine = getMachine(name);
            var speed = settings_time[machine];

            if (speed) {
                return {
                    name: machine, t: item.t, speed: speed, time: item.t / speed, isChange: true
                }
            }
            for (var i = 0; i < item.m.length; i++) {
                var m = item.m[i];
                if (m.name == machine) {
                    return {
                        name: m.name, t: item.t, speed: m.speed, time: item.t / m.speed
                    }
                }
            }
            m = item.m[0];
            return {
                name: m.name, t: item.t, speed: m.speed, time: item.t / m.speed
            }
        }

        var currentItem = null;

        //要计算的目标
        var xqs = [

        ];


        var xqss = [];
        var game_data = {};
        var isDataLoaded = false;
        $(function () { 
            $.ajax({
                url: "./data.json?" + version,
                dataType: "json",
                timeout: 1000000,
                success: function (data) {
                    game_data = data;
                    isDataLoaded = true;
                    f_initIcons();
                },
                error: function () { 
                    alert("游戏资源加载失败，图标将无法显示正常，请刷新再试");
                }
            });

            f_init(); 
        });

        function getGroup() {
            var groups = [];
            $(data).each(function (i, item) {
                if (!item.group) return;

                if ($.inArray(item.group, groups) == -1) {
                    groups.push(item.group);
                }
            });
            return groups;
        }


        function f_fillData() {
            var names = [];

            $(getGroup()).each(function (i, group) {
                var jgroup = $("<optgroup label='" + group + "'></optgroup>");
                $(data).each(function (i, item) {
                    var name = item.name;
                    if (item.group == group) {

                        for (var j = 0; j < item.s.length; j++) {
                            if ($.inArray(item.s[j].name, names) == -1) {
                                names.push(item.s[j].name);
                                jgroup.append("<option value='" + item.s[j].name + "'>" + item.s[j].name + "</option>");
                            }

                        }

                    }

                });
                $("#seldata").append(jgroup);
            });

            for (var i = 110; i < 400; i=i+10) {
                $("#selore").append("<option value='" + i/100 + "'>" + i + "%</option>");
            }
        }
        //找到这个物品的配方
        function getPfs(name) {
            var pfs = [];
            for (var i = 0; i < data.length; i++) {
                var item = data[i];
                for (var j = 0; j < item.s.length; j++) {
                    if (item.s[j].name == name) {
                        var pf = $.extend(true, {}, item);
                        pfs.push(pf);

                    }
                }
            }
            return pfs;
        }
        function getPfTitle(item) {
            var title = [];
            for (var j = 0; j < item.q.length; j++) { 
                if (icons[item.q[j].name]) {
                    title.push("<img class='sicon' src='data:image/png;base64," + icons[item.q[j].name] + "' title='" + item.q[j].name+"' />");
                } else {
                    title.push(item.q[j].name);
                }
                title.push("<sub>" + (item.q[j].n || 1) + "</sub>");
            }
            if (item.q.length) {
                title.push('<img class="to" src="./to.png" />');
            }
            for (var j = 0; j < item.s.length; j++) {
                if (icons[item.s[j].name]) {
                    title.push("<img class='sicon' src='data:image/png;base64," + icons[item.s[j].name] + "' title='" + item.s[j].name +"'/>");
                } else {
                    title.push(item.s[j].name);
                }
                title.push("<sub>" + (item.s[j].n || 1) + "</sub>"); 

            }
            title.push("(" + (item.t || 1).toFixed(0) + "s)");


            return title.join(" ");

        }

        //找到这个物品的配方
        function find(name) {
            function get(item) {
                for (var j = 0; j < item.s.length; j++) {
                    if (item.s[j].name == name) {
                        var o = $.extend(true, {}, item);
                        $.extend(o, item.s[j]);
                        return o;
                    }
                }
            }

            var pf = settings_pf[name];
            if (pf) {
                return get(data[parseInt(pf)]);
            }

            for (var i = 0; i < data.length; i++) {
                var item = data[i];
                for (var j = 0; j < item.s.length; j++) {
                    if (item.s[j].name == name) {


                        return get(item);
                    }
                }
            }
        }


        function f_add3() {
            var value = $("#seldata").val();
            currentItem = find(value);
            xqs.push({
                item: currentItem,
                number: parseInt($("#txtnumber").val())
            });

            update_all();
        }
        var app = null;
        function f_init() {
             
            app = new Vue({
                el: '#result',
                data: {
                    totalEnergy: 0,
                    total: [],
                    xqs: [],
                    icons: icons,
                    items: [],
                    items2: []
                },
                methods: {

                    speedChange: function (item) {

                        settings_time[item.machineName] = parseFloat(item.speed);
                        saveSettingTime();
                        update_all();
                    }
                }
            });
            f_initData();
            f_fillData();
        
            update_all();
            loadSetting();
            loadSettingTime();
            loadSettingPf();
            loadSettingProjects();

            projectsUpdate();
            $("#btnAdd3").click(f_add3);
            $("#btnReset1").click(function () {
                xqs = [];
                update_all();
            });
            $("#btnReset2").click(function () {
                settings = {};
                saveSetting();
                update_all();
            });

            $("#btnReset3").click(function () {
                settings_time = {};
                saveSettingTime();
                update_all();
            });
            $("#selore").change(function () {

                $(data).each(function () {
                    if (this.m) {
                        for (var i = 0; i < this.m.length; i++) {
                            if (this.m[i].name == "矿脉") {
                                this.m[i].speed = 0.5 * 1 * parseFloat($("#selore").val());
                            } if (this.m[i].name == "采矿机") {
                                this.m[i].speed = 0.5 * 6 * parseFloat($("#selore").val());
                            }
                        }
                    }

                });
                update_all();

            })
            $("#btnReset4").click(function () {
                settings_pf = {};
                saveSettingPf();
                update_all();
            });
            $("#btnReset5").click(function () {
                projects = [];
                saveSettingProjects();
                projectsUpdate();
            });
            $("#btnLoadProject").click(function () {

                var value = $("#selprojects").val();
                if (!value) return;
                for (var i = 0; i < projects.length; i++) {
                    if (projects[i].name == value) {
                        xqs = projects[i].value;
                        update_all();
                        return;
                    }
                }
            });
            $("#selmodein").click(function () {
                var value = $("#selmodein").val();
                $(".ms a").each(function () {
                    var name = $(this).attr("data-name");
                    var modein = $(this).attr("data-modein");
                    if (modein == value) {
                        settings[name] = modein;
                    }
                });
                saveSetting();
                update_all();
            });
            $("#isMerge").change(function () {
                update_all();
            });
            $("#hideSource").change(function () {
                update_all();
            });
        }


        var xh_list = [];
        var out_list = [];
        function addXH(name, value) {
            for (var i = 0; i < xh_list.length; i++) {
                var item = xh_list[i];
                if (item.name == name) {
                    item.value += value;  //需求
                    return;
                }
            }
            xh_list.push({ name: name, value: value });
        }
        function addOut(name, value) {
            for (var i = 0; i < out_list.length; i++) {
                var item = out_list[i];
                if (item.name == name) {
                    item.value += value;  //需求
                    return;
                }
            }
            out_list.push({ name: name, value: value });
        }
        //加载需求
        function loadNumber(itemName, n) {
            try {
                var item = find(itemName);
                var info = getValue(itemName);

                addXH(itemName, n);
                for (var i = 0; i < item.s.length; i++) {
                    if (item.s[i].name != itemName) {
                        addOut(item.s[i].name, -1 * n * (item.s[i].n || 1) / (item.n || 1));
                    }
                }
                for (var i = 0; item.q && i < item.q.length; i++) {
                    var q = item.q[i];
                    loadNumber(q.name, n * (q.n || 1) / (item.n || 1));
                }
            } catch (e) { 
                console.log(itemName);
                throw e;
            }
           
        }
        //处理多产出
        function getXhs(itemId) {
            var xhs = [];
            for (var i = 0; i < xh_list.length; i++) {
                var xh = xh_list[i];
                if (!xh.value) continue;
                var itemName = xh.name;
                var item = find(itemName);
                if (item.id == itemId) xhs.push(xh);
            }
            return xhs;
        }
        function doMergeMul(xhs) {
            var maxValue2Index = -1;
            var max = 0;
            for (var i = 0; i < xhs.length; i++) {
                if (xhs[i].value2 > max) maxValue2Index = i;
            }
            for (var i = 0; i < xhs.length; i++) {
                if (i != maxValue2Index && xhs[i].value2 > 0) {
                    var number = xhs[i].value;
                    xhs[i].value2 = 0;
                    var item = find(xhs[i].name);
                    for (var j = 0; j < item.s.length; j++) {
                        addOut(item.s[j].name, number * (item.s[j].n || 1) / (item.n || 1));
                    }
                }
            }
        }
        function mergeMul() {
            var gs = [];
            var ids = [];
            for (var i = 0; i < xh_list.length; i++) {
                var xh = xh_list[i];
                if (!xh.value) continue;
                var itemName = xh.name;
                var item = find(itemName);
                if ($.inArray(item.id, ids) != -1) continue;
                var xhs = getXhs(item.id);

                if (xhs.length > 1) {
                    gs.push(xhs);
                    ids.push(item.id);

                }
            }
            console.log(gs); //gs:分组
            for (var i = 0; i < gs.length; i++) {
                doMergeMul(gs[i]);
            }
        }
        function update_all() {

            var outResult = [];
            xh_list = [];
            out_list = [];

            for (var m = 0; m < xqs.length; m++) {
                var currentItem = xqs[m].item;
                loadNumber(currentItem.name, xqs[m].number);
            }
            function isXqs(name) {
                for (var m = 0; m < xqs.length; m++) {
                    if (xqs[m].item.name == name) return true;
                }
                return false;
            }
            var items = [];
            var items2 = [];
            for (var i = 0; i < xh_list.length; i++) {
                var xh = xh_list[i];
                if (!xh.value) continue;
                var itemName = xh.name;
                var item = find(itemName);
                var info = getValue(itemName);
                if (xh.value > 0) {
                    xh.value2 = xh.value / (1 / info.time) / 60 / (item.n || 1);
                }
            }
            if ($("#isMerge").get(0).checked) {
                //处理合并 多个产出使用了同一个配方
                mergeMul();
            }

            var total = [];
            function addTotal(name, value) {
                for (var i = 0; i < total.length; i++) {
                    var item = total[i];
                    var energy = energyData[name] || 0;
                    if (!item.energy) item.energy = 0;
                    if (item.name == name) {
                        item.value += value;
                        item.energy += energy * (value || 0);
                        return;
                    }
                }
                total.push({ name: name, value: value });
            }
            for (var i = 0; i < xh_list.length; i++) {
                if (!xh_list[i].value) continue;

                var item = find(xh_list[i].name);
                var info = getValue(xh_list[i].name);
                if ($("#hideSource").get(0).checked) {
                    if (!item.q || !item.q.length) {
                        continue;
                    }
                }
                var outitem = {
                    name: xh_list[i].name,
                    number1: xh_list[i].value.toFixed(1),
                    number2: xh_list[i].value2 ? xh_list[i].value2.toFixed(1) : "",
                    time: info.time.toFixed(1),
                    t: info.t.toFixed(1),
                    speed: info.speed.toFixed(1),
                    speedClass: info.isChange ? "time time2" : "time",
                    rowClass: isXqs(xh_list[i].name) ? "xqsrow" : "",
                    machineName: info.name,
                    m: [],
                    pf: []
                };

                addTotal(info.name, Math.ceil(outitem.number2));
                var pfds = getPfs(xh_list[i].name);

                for (var j = 0; j < pfds.length; j++) {
                    var pf = {
                        class: item.id == pfds[j].id ? "pf selected" : "pf",
                        href: item.id == pfds[j].id ? "javascript:void(0)" : "javascript: selectPf(\"" + item.name + "\",\"" + pfds[j].id + "\")",
                        title: getPfTitle(pfds[j])
                    };
                    outitem.pf.push(pf);
                }
                for (var j = 0; j < item.m.length; j++) {
                    var m = {
                        class: info.name == item.m[j].name ? "m selected" : "m",
                        itemName: item.name,
                        href: info.name == item.m[j].name ? "javascript:void(0)" : "javascript: selectM(\"" + item.name + "\",\"" + item.m[j].name + "\")",
                        name: item.m[j].name,
                        showName: item.m[j].name.replace("制作台","")
                    };
                    outitem.m.push(m);

                }
                items.push(outitem);

            }

            for (var i = 0; i < out_list.length; i++) {
                if (!out_list[i].value) continue;
                var item = find(out_list[i].name);
                var info = getValue(out_list[i].name);
                var outitem = {
                    name: out_list[i].name,
                    number1: out_list[i].value.toFixed(1),
                    number2: out_list[i].value2 ? out_list[i].value2.toFixed(1) : "",
                    time: info.time.toFixed(1),
                    t: info.t.toFixed(1),
                    speed: info.speed.toFixed(1),
                    speedClass: info.isChange ? "time time2" : "time",
                    rowClass: "outrow",
                    m: [],
                    pf: []
                };
                items2.push(outitem);
            }

            app.xqs = xqs;
            app.items = items;
            app.items2 = items2;
            app.total = total;
            var energy = 0;
            for (var i = 0; i < total.length; i++) {
                energy += total[i].energy || 0;
            }
            app.totalEnergy = energy.toFixed(2);
        }
        function selectM(name, m) {
            settings[name] = m;
            saveSetting();
            update_all();
        }
        function selectPf(name, value) {
            settings_pf[name] = parseInt(value);
            saveSettingPf();
            update_all();
        }
        function f_tag(obj) {
            var jrow = $(obj).parents("tr:first");
            if (jrow.hasClass("row-tag")) {

                jrow.removeClass("row-tag");
            } else {

                jrow.addClass("row-tag");
            }
        }
        function projectsUpdate() {

            $("#selprojects").html("");
            $(projects).each(function () {
                $("#selprojects").append("<option value='" + this.name + "'>" + this.name + "</option>");
            });
            if (projects.length) {
                $("#projectdiv").show();
            } else {

                $("#projectdiv").hide();
            }
        }
        function f_save() { 
            projects.push({
                name: prompt("输入方案名"),
                value: xqs
            });
            saveSettingProjects();
            projectsUpdate();
        }
        function f_add() {
            if (!isDataLoaded) {
                alert("游戏资源尚未加载完毕")
            }
            $("#UIselector").show(); 
        }
        var icons = {}
        function f_initIcons() {
            var reg = /^(\d)-(\d{1,2})-(.*)+/;
            for (var i = 0; i < game_data.icons1.length; i++) {
                var icon = game_data.icons1[i];
                if (reg.test(icon.name)) {
                    var x = icon.name.match(reg);
                    icons[x[3]] = icon.value;
                } else {
                    icons[icon.name] = icon.value;
                }
            }
            for (var i = 0; i < game_data.icons2.length; i++) {
                var icon = game_data.icons2[i]; 
                if (reg.test(icon.name)) {
                    var x = icon.name.match(reg);
                    icons[x[3]] = icon.value;
                } else {
                    icons[icon.name] = icon.value;
                }
            }
            app.icons = icons;
            $(document).click(function(e){
                if (!$(e.target).closest('#UIselector').length) {
                    $('#UIselector').hide();
                }

            });
            $("#UIselector").html('<div id="selector" class="selector" style="width: ' + w + 'px; height: ' + h + 'px"><div id="tabs"></div></div>').hide();
            var w = 900;
            var h = 700;
            var jimg1 = $("<div class='tab selected'><img src='./component-icon.png'/></div>").appendTo("#tabs");
            var jimg2 = $("<div class='tab'><img src='./factory-icon.png'/></div>").appendTo("#tabs");

            jimg1.click(function () {
                jicons2.removeClass("icons-selected");
                jicons.addClass("icons-selected");
                jimg2.removeClass("selected");
                jimg1.addClass("selected");
            });
            jimg2.click(function () {
                jicons.removeClass("icons-selected");
                jicons2.addClass("icons-selected");
                jimg1.removeClass("selected");
                jimg2.addClass("selected");
            });

            var jicons = $('<div class="icons icons-selected"></div>').appendTo("#selector");
            addIcons(jicons, game_data.icons1);
            var jicons2 = $('<div class="icons"></div>').appendTo("#selector");
            addIcons(jicons2, game_data.icons2);

            function addIcons(jicons, icons) {
                jicons.width(w - 80).height(h - 220);

                for (var i = 0; i < 7; i++) {
                    var jrow = $("<div class='iconrow'></div>").appendTo(jicons);
                    for (var j = 0; j < 12; j++) {
                        var jicon = $("<div class='icon'><div class='s'></div></div>").appendTo(jrow);
                        jicon.click(function () {
                            var name = $(this).attr("data-name");
                            if (!name) return;
                            currentItem = find(name);
                            xqs.push({
                                item: currentItem,
                                number: parseInt($("#txtnumber").val())
                            });
                            update_all();
                            $("#UIselector").hide();
                        })
                    }
                }

                for (var i = 0; i < icons.length; i++) {
                    var icon = icons[i];
                    var reg = /^(\d)-(\d{1,2})-(.*)+/;
                    if (reg.test(icon.name)) {
                        var x = icon.name.match(reg);
                        jicons.find(">.iconrow:eq(" + (parseInt(x[1]) - 1) + ")")
                            .find(">.icon:eq(" + (parseInt(x[2]) - 1) + ")")
                            .html("").append("<img src='data:image/png;base64," + icon.value + "' />").attr("data-name", x[3]).attr("title", x[3]);
                    }
                }
            }
        }

    </script>
    <style type="text/css">
        .sicon{
            width:24px;height:24px;
        }
        .selector, .layui-layer-demo {
            background: #4A5C72;
        }
        .selector{

        }
            .selector .icons {
              
                flex-direction: column;
                padding: 20px;
                display:none;
            }
            .selector .icons-selected {
                display: -webkit-flex;
                display: flex;
            }
        .selector .icons .iconrow {
            display: -webkit-flex;
            display: flex;
            flex: auto;
        }
                .selector .icons .icon:hover {
                    background: #3F6D84;
                }
                .selector .icons .icon {
                    flex: auto;
                    margin-right: 2px;
                    margin-bottom: 2px;
                    cursor: pointer;
                    text-align: center;
                }
                    .selector .icons .icon .s ,.selector .icons .icon img {
                        width: 50px;
                        height: 50px;
                        margin-top:10px;
                    }
                   
        #tabs {
            margin-top: 20px;
            margin-left: 20px;
            height: 80px;
        }
        .layui-layer-page .layui-layer-content{
            overflow:hidden;
        }
        .icons {
            background: #2D3241;
            clear: both;
            margin-top: 40px;
            margin-left: 20px;
        }
            .icons .icon {
                background: #364450;
            }
        #tabs img {
            width: 64px;
            height: 64px;
        }
        #tabs .tab {
            padding: 10px;
            cursor: pointer;
            float:left;
        }
            #tabs .tab.selected {
                background: #506777;
            }

            .ms, .pfs {
                display: flex;
            }

        .m, .pf {
            display: block;
            margin: 3px;
            padding: 3px 8px;
            font-size: 12px;
            color:white;
            text-decoration: none;
            background: #878787;
        }
        .m{ 
            text-decoration: underline;
        }
        .selected {
            background: #42586c;
            color: white;
        }
        a.pf {
            color: white;
        }
        a.selected {
            color: white;
            text-decoration: none;
        } 
        .time {
            border: 1px #cfcfcf solid;
            width: 60px;
            padding: 4px;
            outline: none;
        }

        .time2 {
            border-color: #ef1f1f;
        }

       select {
            height: 30px;
            line-height: 30px;
        }

        button {
            height: 30px;
        }

        .list {
            border: 1px #d3d3d3 dashed;
            margin: 10px;
            padding: 10px;
        }

        #txtnumber, #txtore {
            width: 40px;
            height: 24px;
            line-height: 30px;

        }
        #txtore {
            margin-left:5px;
        }
        .name {
                width: 200px;
            }



        table {
            width: 100%;
            border-collapse: collapse;
            border: none;
        }

        .header td {
            background: #f2f2f2;
        }

        td {
            padding: 10px 30px;
            border: 1px dashed #d3d3d3;
        }

        .xqsrow td {
            background: #fff2f2;
        }

        .outrow td {
           
        }

        .to {
            color: black;
        }

        .op {
            display: none;
            font-size: 12px;
        }

            .op a {
                color: #333;
            }

        td:hover .op {
            display: inline-block;
        }

        .row-tag td {
            background: #e2e2e2;
        }
        #UIselector {
            position: absolute;
            left: 50px;
            top: 50px;
        }
    </style>
</head>
<body style="padding:5px;">
    每分钟数量：<input type="text" id="txtnumber" value="60" />
    <a href="javascript:f_add()" style="margin-left:10px;margin-right:10px;"><img src="" /></a>
    <select id="seldata"></select>


    <button id="btnAdd3">
        增加
    </button>
    <button id="btnReset1">
        重置
    </button>
    <div style="margin-top:5px;">
        <button id="btnReset2">
            重置设备
        </button>
        <button id="btnReset3">
            重置速度
        </button>
        <button id="btnReset4">
            重置配方
        </button>
        <input type="checkbox" id="isMerge" checked />合并同配方多产物
        <input type="checkbox" id="hideSource" />隐藏原料
        <select id="selmodein">
            <option value="制作台Mk.Ⅰ">制作台Mk.Ⅰ</option>
            <option value="制作台Mk.Ⅱ">
                制作台Mk.Ⅱ
            </option>
            <option value="制作台Mk.Ⅲ">制作台Mk.Ⅲ</option>

        </select>
        采矿效率：
        <select id="selore">
            <option value="1">100%</option>
        </select>
        <span id="projectdiv" style="display:none;">
            <select id="selprojects"></select>
            <button id="btnLoadProject">
                加载方案
            </button>
            <button id="btnReset5">
                重置方案
            </button>
        </span>
    </div>
    <div id="UIselector" style="display:none;">

    </div>
    <div id="result">
        <div class="list">
            <div v-for="x in xqs">
                {{ x.item.name  }} * {{x.number}}
            </div>
            <div v-if="xqs && xqs.length">
                <button onclick="f_save()">保存方案</button>
            </div>
        </div>

        <div class="list">
            <table border="0" cellspacing="0" cellpadding="0">
                <tbody>
                    <tr class="header">
                        <td style="width:100px;">物品</td>
                        <td style="width:100px;">
                            每分钟需求
                        </td>
                        <td style="width:100px;">设备数量</td>
                        <td>
                            配方
                            <br /><span style="font-size:12px">(可选)</span>
                        </td>
                        <td>制作于</td>
                        <!--<td>设备制作速度<br /><span style="font-size:12px">(可自定义)</span></td>-->
                        <!--<td style="width:150px;">最终速度(秒)</td>-->
                    </tr>
                    <tr v-for="item in items" v-bind:class="item.rowClass">
                        <td>
                            <img v-bind:src="'data:image/png;base64,' + icons[item.name]" style="width:40px;height:40px;" v-if="icons[item.name]" v-bind:title="item.name" />
                            <span class="name" v-else=v-else>{{item.name}}</span>
                            <span class="op"><a href="javascript:void()" onclick="f_tag(this)">标注</a></span>
                        </td>
                        <td><span class="number1">{{item.number1}}</span></td>
                        <td><span class="number2">{{item.number2}}</span></td>
                        <td>
                            <div class="pfs">
                                <a v-for="pf in item.pf" v-bind:class="pf.class" v-bind:href='pf.href' v-html="pf.title"  ></a>
                            </div>
                        </td>
                        <td>
                            <div class="ms">
                                <a v-bind:data-modein="m.name" v-bind:data-name="m.itemName" v-for="m in item.m" v-bind:title="m.title" v-bind:class="m.class" v-bind:href='m.href'>
                                    {{m.showName}}
                                </a>
                            </div>
                        </td>
                        <!--<td>
                            <input type="text" v-bind:class="item.speedClass" v-on:change="speedChange(item)" v-model="item.speed" />
                        </td>
                        <td>
                            {{item.time}}
                        </td>-->
                    </tr>
                    <tr class="total">
                        <td colspan="2" align="right">合计： </td>
                        <td colspan="5">
                            <span v-for="item in total"> {{item.name}}*{{item.value}} </span>
                            <br />
                            <span>
                                耗能估算：{{totalEnergy}}M
                            </span>
                        </td>
                    </tr>
                    <tr class="" v-if="items2 && items2.length">
                        <td colspan="5" align="left">多余产物 <br />(负数代表多余、正数代表缺少，如1000则需要额外补齐，-1000则需要额外消耗) </td>
                    </tr>
                    <tr v-for="item in items2" v-bind:class="item.rowClass">
                        <td>
                            <span class="name">
                                <img v-bind:src="'data:image/png;base64,' + icons[item.name]" style="width:40px;height:40px;" v-if="icons[item.name]" v-bind:title="item.name" />
                                <span class="name" v-else=v-else>{{item.name}}</span> 
                            </span>
                        </td>
                        <td><span class="number1">{{item.number1}}</span></td>
                        <td><span class="number2">{{item.number2}}</span></td>
                        <td></td>
                        <td></td>
                        <!--<td></td>
                        <td></td>-->
                    </tr>


                    <tr class="">
                        <td colspan="1" align="right">备注 </td>
                        <td colspan="4">
                            参考数据：传送带360/m 高速传送带720/m 极速传送带1800/m <br />
                            如果【增加】后没反应可以试一下重置配方/设备<br />
                            可以对某个物品进行标注(改颜色)比如已经完成生产线的物品<br />
                            采矿机默认按6个矿脉计算，原油萃取站按4/s计算<br />
                            轨道采集重氢按0.02/s 其他按1/s<br />
                            有问题联系QQ1028-21-03
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</body>
</html> 